package com.tzxscu.hosdrool.drools;

import com.tzxscu.hosdrool.models.BillItems;
import com.tzxscu.hosdrool.models.BillItemsBean;
import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;

import java.util.ArrayList;
import java.util.List;

public class droolsapi_2 {
    private static List<BillItemsBean> listbill = new ArrayList<>();
    public  static String drools(List<BillItems> billItems){
        KieServices ks = KieServices.Factory.get();
        KieContainer kieContainer = ks.getKieClasspathContainer();
        KieSession kieSession = kieContainer.newKieSession("rulesSession");
        BillItemsBean billItems1 = new BillItemsBean();
        List<BillItemsBean> billItemsBeans = new ArrayList<>();
        kieSession.setGlobal("billret",billItemsBeans);
        kieSession.insert(billItems);
        kieSession.fireAllRules();
        kieSession.dispose();
        System.out.println(billItemsBeans.toString());
        return billItemsBeans.toString();
    }
}
